package com.ccsoft.atools.controller;

import com.ccsoft.atools.model.Vue3user;
import com.ccsoft.atools.model.Vue3userDTO;
import com.ccsoft.atools.model.Vue3userPageParam;
import com.ccsoft.atools.service.Vue3userService;
import com.ccsoft.atools.utils.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
@RequestMapping("/vue3user")
public class Vue3userController {
    @Autowired
    private Vue3userService service;

    @GetMapping("/selectAll")
    public JsonResult selectAll() {
        return JsonResult.ok(service.selectAll());
    }

//    @PostMapping("/list")
//    public JsonResult list(@RequestBody Vue3userDTO record){
//        return JsonResult.ok(service.selectByParamLike(record));
//    }

    @PostMapping("/listp")
    public JsonResult listp(@RequestBody Vue3userPageParam record) {
//        return JsonResult.ok(service.selectByParamLike(record));
        System.out.println(record);
        List<Vue3user> ret = service.selectByParamLike(record);
        return JsonResult.ok(ret);
    }

    @PostMapping("/delete")
    public JsonResult deleteOne(@RequestBody Map<String, Integer> params) {
        System.out.println(params);
        Integer id = params.get("id");
        return JsonResult.ok(service.deleteByPrimaryKey(id));
    }

    @PostMapping("/insert")
    public JsonResult insert(@RequestBody Vue3user record) {
        return JsonResult.ok(service.insertSelective(record));
    }

    @PostMapping("/update")
    public JsonResult update(@RequestBody Vue3user record) {
        int ret = 1 / 0;
        return JsonResult.ok(service.updateByPrimaryKey(record));
    }
}
